package com.example.dao;

import com.example.entity.Admininfo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author 涛某
 * @version 1.0
 * @date 2024/3/17 10:15
 */
@Repository
public interface AdminInfoDao extends Mapper<Admininfo> {

    @Select("select * from admin where name = #{name} and password = #{password}" )
    Admininfo findByNameAndPassowrd(@Param("name") String name, @Param("password") String password);


    @Select("select * from admin where id = #{id}")
    Admininfo FindById(Long id);


    @Update("update admin set name = #{name},sex=#{sex},age = #{age}, phone = #{phone} where id = #{id}")
    void update(Admininfo admininfo);

    @Insert("insert into admin(name,sex,age,phone,password) values(#{name},#{sex},#{age},#{phone},#{password})")
    void add(Admininfo admininfo);

    @Select("select * from admin where name = #{name}")
    Admininfo FindByName(@Param("name") String name);


    @Select("select * from admin")
    List<Admininfo> findAll();

    @Delete("delete from admin where id = #{id}")
    void deleteById(Long id);

    @Select("select * from admin where name like concat('%',#{name},'%')")
    List<Admininfo> findByNamePage(@Param("name") String name);
}
